home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0002_Clear Keyboard Buffer.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  801b  |  22 lines

  1. {
  2. EDWIN CALIMBO
  3.  
  4. ║ I need to know how I can clear the keyboard buffer.
  5. ║ The reason I need to do this is that in a loop I'm reading in
  6. ║ one Character and then calling a Procedure which returns to the
  7. ║ loop For the next Character to be read.  But sometimes it takes the
  8. ║ next Character in the buffer that my have been a result of just holding
  9. ║ down a key For to long.
  10.  
  11.  
  12.   You can clear any keys in the keyboard buffer by using the following loop:
  13. }
  14.       While KeyPressed Do
  15.         ch := ReadKey;
  16. {
  17.   Another way to clear the keyboard buffer is to set the keyboard head
  18.   equal to the keyboard tail and the keyboard buffer as a circular buffer.
  19.   You can set the tail equal to the head this way:
  20. }
  21.       MemW[$0000:$041C] := MemW[$0000:$041A];      { flush keyboard buffer }
  22.